<template>
  <div class="app-container">
    <div class="issue" v-if="msg.messageType == '1'">
      <el-button type="primary" size="mini" icon="el-icon-document-add">创建维修工单</el-button>
    </div>
    <div class="msg">
      <el-descriptions :column="1">
        <el-descriptions-item label="发件人">{{ msg.senderName }}</el-descriptions-item>
        <el-descriptions-item label="发送时间">{{ msg.sendTime }}</el-descriptions-item>
        <el-descriptions-item label="消息类型"><dict-tag :options="dict.type.sys_message_type" :value="msg.messageType"/></el-descriptions-item>
        <el-descriptions-item label="内容">
          <span>{{msg.content}}</span>
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script>
import { getMessage, updateMessage } from "@/api/business/message";
export default {
  name: "msgdetails",
  dicts: ['sys_message_type'],
  data() {
    return {
      id: null,
      msg: {}
    };
  },
  created() {
    this.id = this.$route.params && this.$route.params.id;
    if(this.id) {
      this.readMSg()
      this.getMessage()
    }
  },
  methods: {
    readMSg() {
      updateMessage({id: this.id, isRead: 1})
    },
    getMessage() {
      getMessage(this.id).then(res => {
        this.msg = res.data
      })
    }
  }
};
</script>
<style scoped lang="scss">
.issue {
  width: 100%;
  border: 1px solid #d8dce5;
  border-radius: 2px;
  padding: 10px;
  text-align: right;
}

.msg {
  padding: 20px 50px;
}
</style>

